import request from '@renderer/utils/request';
import { useConfigStore } from '@renderer/stores/configStore'

// 辅助函数：延迟获取基础 URL（确保在应用挂载后执行）
const getBaseUrl = () => {
  const configStore = useConfigStore();
  return configStore.config.comfyuiPath;
};

export function loraApi() {
    return {
      getTags: () => {
        return request({
          url: getBaseUrl() + 'lora/list',
          method: 'get',
        })
      },
      getComfyuiInfo: () => {
        return request({
          url: getBaseUrl() + 'object_info',
          method: 'get'
        })
      },
      scanAndCompleteLoras: ()=>{
        return request({
          url: getBaseUrl() + 'command/check-lora-all',
          method: 'post'
        })
      },
      scanAndCompleteCivitai: ()=>{
        return request({
          url: getBaseUrl() + 'command/global-fetch-civitai-info',
          method: 'post'
        })
      }
    }
}
    